﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using System.Reflection;
namespace Viewer.BusinessObject.BusinessEntities
{
    [Serializable()]
    public partial class QUNhomQuyenByModule_NguoiDung : BusinessBase
    {
        public void SaveDataList(int nhanVienId, List<QUNhomQuyenByModule_NguoiDung> lstData)
        {
            var query = (from a in this.Context.QUNhomQuyenByModule_NguoiDungs
                         where a.NguoiDungID.Equals(nhanVienId)
                         select a).ToList();
            if (query.Count > 0)
            {
                this.Context.QUNhomQuyenByModule_NguoiDungs.DeleteAllOnSubmit(query);
                this.Context.SubmitChanges();
            }
            if (lstData.Count > 0)
            {
                foreach (QUNhomQuyenByModule_NguoiDung item in lstData)
                {
                    QUNhomQuyenByModule_NguoiDung newItem = new QUNhomQuyenByModule_NguoiDung();
                    newItem.NguoiDungID = item.NguoiDungID;
                    newItem.NhomQuyenByModuleID = item.NhomQuyenByModuleID;
                    this.Context.QUNhomQuyenByModule_NguoiDungs.InsertOnSubmit(newItem);
                }
            }
            this.Context.SubmitChanges();
        }
    }
}